<template>
  <fragment>
    <template v-for="menu in menuList">
      <el-submenu v-if="menu.children.length>0" :index="menu.path" :key="menu.path">
        <template slot="title" style="font-size:15px;font-weight:600">
          <i :class="menu.icon"></i>
          <span style=" font-size:15px;font-weight:600;" slot="title">{{menu.label}}</span>
        </template>
        <!-- 循环调用子菜单-->
        <menu-item :menuList="menu.children"></menu-item>
      </el-submenu>
      <el-menu-item @click="selectMenu(menu)" v-else :index="menu.path" :key="menu.path">
        <i :class="menu.icon"></i>
        <span slot="title" style="font-size:15px;font-weight:600">{{menu.label}}</span>
      </el-menu-item>
    </template>
  </fragment>

  <!-- <div v-for="(item,index) in menuList" :index="index" :key="index">
      <el-submenu  :index="item.path">
        <template slot="title" >
          <i class="el-icon-menu"></i>
          {{item.label}}
        </template>
        <el-menu-item
          v-for="(itemlist,index2) in item.children"
          :index="itemlist.path"
          :class="$route.path==itemlist.path ? 'is-active':''"
          :key="index2"
          @click="selectMenu(itemlist)"
        >{{itemlist.label}}</el-menu-item>
      </el-submenu>
  </div>-->
</template>

<script>
import MenuItem from "./MenuItem.vue";
export default {
  name: "MenuItem",
  props: ["menuList"],
  components: {
    MenuItem
  },
  data() {
    return {};
  },
  methods: {
    selectMenu(item) {
      // ths.saveNavState(item.path);
      this.$store.commit("selectMenu", item);
      this.$router.push({ name: item.name });
    }
  }
};
</script>

<style scoped>

</style>